﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using KMF.Common;

namespace KMF.DAL
{
    public partial class ProviderDb
    {
       
        public static List<ProviderListCateHomeDto> GetProviderByCate(string categoryId)
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_Product_GetAllProviderByCate");
            try
            {
                //var keywords = BuildListKeywordV2(keyword);
                command.Parameters.Add(dao.CreateParameter("@CategoryId", categoryId));
                var result = dao.GetDTOList<ProviderListCateHomeDto>(ref command);
                return result;
            }
            finally
            {
                command.Connection.Close();
            }
        }

        // PROVIDER FIL
        public static List<ProviderFilterDto> GetProviderFilter(CategoryFilterModel modelFil)
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_Provider_SelectByFilter");
            try
            {
                command.Parameters.Add(dao.CreateParameter("@CategoryId", modelFil.CategoryId));
                command.Parameters.Add(dao.CreateParameter("@PriceMin", modelFil.PriceMin));
                command.Parameters.Add(dao.CreateParameter("@PriceMax", modelFil.PriceMax));
                command.Parameters.Add(dao.CreateParameter("@RateMin", modelFil.RateMin));
                command.Parameters.Add(dao.CreateParameter("@RateMax", modelFil.RateMax));
                command.Parameters.Add(dao.CreateParameter("@Providers", modelFil.Providers));
                command.Parameters.Add(dao.CreateParameter("@Colors", modelFil.Colors));
                command.Parameters.Add(dao.CreateParameter("@Sizes", modelFil.Sizes));
                command.Parameters.Add(dao.CreateParameter("@Attrs", modelFil.Attrs));

                var result = dao.GetDTOList<ProviderFilterDto>(ref command);
                return result;
            }
            finally
            {
                command.Connection.Close();
            }
        }
        // END PROVIDER FIL
    }
}
